package com.le.tester.javaThink.fifth.chapter24_ConcurrentProgramming;

import java.util.stream.Stream;

/**
 * createTime：2021/8/23 14:25
 * description：流异常
 */
public class StreamExceptions {
    static Stream<Breakable> test(String id, int failCount) {

        return Stream.of(new Breakable(id, failCount))
                .map(Breakable::work)
                .map(Breakable::work)
                .map(Breakable::work)
                .map(Breakable::work);
    }

    public static void main(String[] args) {
        test("A", 1);
        test("B", 2);
        Stream<Breakable> c = test("C", 3);

        test("D", 4);
        test("E", 5);

        System.out.println("Entering try");


        try {
            c.forEach(System.out::println);
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }
    }
}
